<template>
  <div class="gz-card">
    <div class="title-box">
      <slot name="title">
        <div class="card-item" v-if="content[0].title">
          <div class="card-item" style="flex: 1;">
            <div class="item-title">
              {{content[0].title}}
            </div>
            <div class="item-value">
              {{content[0].value}}
            </div>
          </div>
          <div class="item-value" :style="{color: content[0].statusColor,flexShrink: 0}" v-if="content[0].statusDesc">
            {{content[0].statusDesc}}
          </div>
        </div>
      </slot>
      <div class="left-dot"></div>
      <div class="right-dot"></div>
    </div>
    <div class="content-box">
      <slot name="content">
        <div class="card-items" v-if="content.length > 0">
          <div class="card-item" v-for="(item,index) in content" :key="index" v-if="index > 0" :style="{flex: `0 0 ${item.width ? item.width : '100%'}`}">
            <div class="item-title">{{item.title}}</div>
            <div class="item-value">{{item.value}}</div>
            <!-- <div v-if="item.type == 'tag'" class="item-value-tag" :class="'tag-' + (item.priority == 1 ? 'danger' : item.priority == 2 ? 'warn' : item.priority == 3 ? 'primary' : 'default')">{{item.value}}</div> -->
          </div>
        </div>
      </slot>
    </div>
    <div class="footer-box">
      <slot name="footer">
        <div class="btn-group" v-if="content[content.length - 1].key == 'action'">
          <div class="btn" :class="btn.type ? 'btn-' + btn.type : ''" v-for="(btn,bIndex) in content[content.length - 1].btnList" :key="bIndex" @click="handleBtnClick(btn.fun,content[content.length - 1].row)">{{btn.name}}</div>
        </div>
      </slot>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      title: {
        type: Object,
        default: () => {
          return {
            title: '',
            value: ''
          }
        }
      },
      content: {
        type: Array,
        default: () => []
      },
      btnList: {
        type: Array,
        default: () => []
      }
    },
    data() {
      return {

      }
    },
    methods: {
      handleBtnClick(name,row) {
        // if(name == 'qianshou')
        this.$emit('click',name,row)
      }
    }
  }
</script>

<style lang="less" scoped>
  .gz-card {
    background-color: #FFF;
    border-radius: 8px;
    padding: 0 16px;
    box-sizing: border-box;
    margin-top: 12px;
    overflow: hidden;
    .title-box {
      padding: 16px 0;
      border-bottom: 1px dashed #C9CDD4;
      position: relative;
      // overflow: hidden;
    }
    .content-box {
      padding: 14px 0;
    }
    .footer-box {
      padding-bottom: 14px;
    }
    .btn-group {
      display: flex;
      flex-direction: row-reverse;
    }
    .btn {
      width: 80px;
      padding: 6px 0;
      color: #86909C;
      font-size: 14px;
      font-weight: 400;
      text-align: center;
      border: 1px solid #C9CDD4;
      border-radius: 30px;
      margin-left: 10px;
    }
    .btn-primary {
      color: #FF4A32;
      font-size: 14px;
      font-weight: 400;
      text-align: center;
      border: 1px solid #FF4A32;
      border-radius: 30px;
      margin-left: 10px;
    }
    .card-items {
      display: flex;
      flex-wrap: wrap;
    }
    .card-item {
      display: flex;
      // align-items: center;
      margin-top: 12px;
      .item-title {
        flex-shrink: 0;
      }
    }
    .card-item:first-child {
      margin-top: 0;
    }

    .item-title {
      font-size: 14px;
      color: #86909C;
      font-weight: 400;
    }

    .item-value {
      font-size: 14px;
      color: #1D2129;
      font-weight: 400;
    }

    .left-dot {
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background-color: #F4F4F4;
      position: absolute;
      bottom: -6px;
      left: -22px;
    }

    .right-dot {
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background-color: #F4F4F4;
      position: absolute;
      bottom: -6px;
      right: -22px;
    }

    .item-value-tag {
      font-size: 12px;
      font-weight: 400;
      padding: 2px 4px;
      border-radius: 2px;
    }

    .tag-danger {
      color: #F53F3F;
      background-color: #FFECEC;
    }
  }
</style>
